// ==UserScript==
// @name           SFEE Clone Feature
// @namespace      oasis.mitra.com
// @description    Add the clone frame to a tracker
// @include        http://oasis.mitra.com*/sf/go/artf*
// ==/UserScript==
var attachments = document.evaluate(
    "//td[@class='ItemDetailName']",
    document,
    null,
    XPathResult.ANY_TYPE,
    null);
    
var attachment = attachments.iterateNext();

while (attachment) {
    if( attachment.innerHTML.indexOf('Attachments:') >= 0 )
    {
  	break;
    }
    attachment = attachments.iterateNext();
}

var tableRow = attachment.parentNode;
var table = tableRow.parentNode;

var newRow = document.createElement("tr");
newRow.setAttribute("rowspan", "4");
var newCell = document.createElement("td");
newCell.setAttribute("colspan", "2");
var iframe = document.createElement("div");
iframe.innerHTML = "<iframe src='http://wtlswweb02.aqua.mitra.com:8080/SfChart/CloneArtifact.jsp' width='100%' height='25%' scrolling='horizontal' frameborder='0' name='linkedApplication' id='linkedApplication' marginwidth='0' marginheight='0'/>";

newCell.appendChild(iframe);
newRow.appendChild(newCell);

table.appendChild(newRow);

GM_log("the iframe html is: " + iframe.innerHTML);

//var artfHtml = artfTable.innerHTML;